package com.branches.imgs;

import com.google.gson.Gson;

import java.util.List;

public class RecogParse {
    private CombineImage combineImage;

    private RecogResult recogResult;


    public RecogParse(CombineImage image, String result) {
        combineImage = image;
        recogResult =  new Gson().fromJson(result, RecogResult.class);
    }

    //
    public void parse() {
        List<CombineItem> itemList = combineImage.getItems();
        List<RecogResult.Word> wordList = recogResult.getWords_result();
        itemList.forEach(item -> {
            // 将识别结果放到对于的CombineItem
            wordList.forEach(word -> {
                item.addWord(word);
            });

            item.parse();
        });
        System.out.println(itemList.stream().filter(item-> item.getWordList() != null).count());
    }
}
